import * as actionType from './constant'
import {getTopList,getRankingList} from 'services/ranking'


const changeTopListAction = res => ({
  type : actionType.CHANGE_TOP_LIST,
  topList : res.list
})

export const changeCurrentIndex = index =>({
  type : actionType.CHANGE_CURRENT_INDEX,
  index
})

export const changePlaylistDetailAction = res => ({
  type : actionType.CHANGE_DETAIL_LIST,
  playlistDetail : res.playlist
})



export const getTopListAction = () => {
  return dispatch => {
    getTopList().then(res=>{
      dispatch(changeTopListAction(res));
    })
  }
}

 export const getDetailListAction = (id) => {
  return dispatch => {
    getRankingList(id).then(res=>{
      dispatch(changePlaylistDetailAction(res))
    })
  }
} 

